SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO



CREATE PROCEDURE dbo.[DnnProduct_Journal_Comment_Save]
@JournalId int,
@CommentId int,
@UserId int,
@Comment nvarchar(2000),
@CommentXML xml
AS
IF EXISTS(SELECT * FROM dbo.[DnnProduct_Journal_Comments] WHERE JournalId = @JournalId AND CommentId = @CommentId)
	BEGIN
		UPDATE dbo.[DnnProduct_Journal_Comments]
			SET Comment = @Comment,
				CommentXML = @CommentXML,
				DateUpdated = GETUTCDATE()
			WHERE JournalId = @JournalId AND CommentId = @CommentId
	END
ELSE
	BEGIN
	INSERT INTO dbo.[DnnProduct_Journal_Comments]
		(JournalId, UserId, Comment, CommentXML, DateCreated, DateUpdated)
		VALUES
		(@JournalId, @UserId, @Comment, @CommentXML, GETUTCDATE(), GETUTCDATE())
	SET @CommentId = SCOPE_IDENTITY()
	END
SELECT @CommentId


GO
